package com.fzshang.shopping.api;

import com.fzshang.shopping.commen.service.XbxWxService;
import com.github.binarywang.wxpay.bean.result.WxPayUnifiedOrderResult;
import com.github.binarywang.wxpay.exception.WxPayException;
import me.chanjar.weixin.common.api.WxConsts;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.mp.api.WxMpInMemoryConfigStorage;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author 张子艺
 * @packge com.xbxkj.controller
 * @data 2019-06-03 11:20
 * @project Metaphysics
 */
@Controller
@RequestMapping("/test")
public class test {
    @Autowired
    XbxWxService xbxWxService;
    @RequestMapping(value = "/test1",method = RequestMethod.GET)
    @ResponseBody
    public WxPayUnifiedOrderResult test1() throws WxErrorException, WxPayException {
        return  null;
       // return xbxWxService.mpPayOrder(1, OrderIdUtil.gen("TR",1L));
    }

    /**
     * 生成首页地址
     * @param args
     */
    public static void main(String args[]) {
        WxMpInMemoryConfigStorage config = new WxMpInMemoryConfigStorage();
        config.setAppId("wx587b3d919947dc96");
        config.setSecret("82f7b138eda437bbc4c2b2d4aa9dfb27");
        config.setToken("feng2969946807");
        WxMpService wxMpService = new WxMpServiceImpl();
        wxMpService.setWxMpConfigStorage(config);
        String a = wxMpService.oauth2buildAuthorizationUrl("http://1f25kxsz9r.52http.net/wx/user/login", WxConsts.OAuth2Scope.SNSAPI_USERINFO, null);
        System.err.println(a);
    }
}
